<?php
    /**
    * View.php
    * 
    * @author Osuvaldo Ramos <xdracox@gmail.com>
    * @copyright Copyright (c) 2008, Osuvaldo Ramos
    * @license http://www.opensource.org/licenses/bsd-license.php
    * @package Atman
    */
    
    /**
    * The View class is the base class for all the types of views available.
    * It also contains a factory method for creating views.
    * @package Atman
    */
    abstract class AT_View
    {
        /**
        * Stores the instance of the module that this view represents.
        * @var AT_Module
        */
        protected $module;
        
        /**
        * The factory method creates Views using a factory pattern.
        * @param string $view The name of the requested view.
        * @return AT_View
        */
        public static function factory($view, AT_Module $module)
        {
            $className = 'AT_View_'.$view;
            $ref = new $className($module);
            
            if ( $ref instanceof AT_View )
            {
                return $ref;
            }
            else
            {
                $msg = 'Invalid view class.';
                $this->reportError($msg, PEAR_LOG_ALERT);
            }
        }
        
        /**
        * The constructor stores the module for later use.
        * @param AT_Module $module The module this view represents.
        */
        public function __construct(AT_Module $module)
        {
            $this->module = $module;
        }
        
        /**
        * Displays the module data using the current view.
        * @return void
        */
        public abstract function display();
        
        /**
        * __destruct()
        */
        public function __destruct()
        {
        }
    }
?>
